

//引入微信文件
document.write("<script src='http://res.wx.qq.com/open/js/jweixin-1.0.0.js'></script>");
//记录分享信息

//根据QueryString参数名称获取值
function getQueryStringByName(name) {
    var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1) {
        return "";
    }
    return result[1];
}



//分享后记录数据
//function RecordShare(type, remark) {
//    _SubType = type;
//    _Remark = remark;
//    _Log(_LogURL, _App, _OpenID, _Mobile, "分享", _SubType, _Method, _Parameter, _Content, _Remark);
//}
$(function () {
    pengyouquanTitle = " 测试你的足球绝杀DNA！大力神杯拿走不谢！";
    wxtitle = " 测试你的足球绝杀DNA！大力神杯拿走不谢！";
    wxdesc = "万万没想到你是这样的 明日之星！";

    wxlink = "http://sjb.m.openinfor.com/Home/index";
    wximgUrl = "http://sjb.m.openinfor.com/Content/pshare.jpg";
    onloadFun();
});
function onloadFun() {

    $.ajax({
        async: false,
        //url: 'http://share.test.wx.fractalist.com.cn/GetWXJsApiByAjax.aspx?urlStr=' + encodeURIComponent(window.location.href.split('#')[0]),
        url: 'http://benz.wx.fractalist.com.cn/wxapi/wxjsconfig?Url=' + encodeURIComponent(window.location.href.split('#')[0]),
        type: "GET",
        dataType: 'json',
        timeout: 5000,
        beforeSend: function () {
        },
        success: function (json) {
            console.log(json);
            wx.config({
                debug: false,
                appId: json["appId"],
                timestamp: json["timestamp"],
                nonceStr: json["nonceStr"],
                signature: json["signature"],
                jsApiList: [
                       'checkJsApi',
                       'onMenuShareTimeline',
                       'onMenuShareAppMessage',
                       'scanQRCode',
                ]
            });

            wx.ready(function () {
                document.getElementById('audio').play();
                wx.onMenuShareAppMessage({
                    title: wxtitle,
                    desc: wxdesc,
                    link: wxlink,
                    imgUrl: wximgUrl,
                    trigger: function (res) {

                    },
                    success: function (res) {


                    },
                    cancel: function (res) {
                        // alert("cancel");
                    },
                    fail: function (res) {
                    }
                });

                wx.onMenuShareTimeline({
                    title: pengyouquanTitle,
                    link: wxlink,
                    desc: wxdesc,
                    imgUrl: wximgUrl,
                    trigger: function (res) {
                    },
                    success: function (res) {


                    },
                    cancel: function (res) {
                        // alert("cancel");
                    },
                    fail: function (res) {
                        // alert("fail");
                    }
                });
            });
        },
        complete: function (XMLHttpRequest, textStatus) {

        },
        error: function (xhr, textStatus) {
            // alert(textStatus);
            console.info(xhr);
        }
    });
}

//获取cookies
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null
}
